package com.jxau.util;

public class FileUtil {
//    public static String HEAD_PHOTO_PATH="D:/web/vue-test/fourth-vue/static/head-photo/";
    public static String HEAD_PHOTO_PATH="/usr/local/dist/static/head-photo/";
    /**
     * 获取文件名后缀，若无后缀（无.）或.在最后、.在最前面则返回null
     * @param fileName
     * @return 文件名后缀(如: JPG)
     */
    public static String getFileTail(String fileName) {
        byte[] bytes = fileName.getBytes();
        for (int i = bytes.length - 1; i >= 0; i--) {
            if (bytes[i] == '.') {
                int tailLength = bytes.length - i - 1;
                if (tailLength == 0 || i == 0) {
                    return null;
                }
                byte[] tailBytes = new byte[tailLength];
                for (int j = 0; j < tailLength; j++) {
                    tailBytes[j] = bytes[i + j + 1];
                }
                return new String(tailBytes);
            }
        }
        return null;
    }

}
